package com.mosai.alignpro.view;

import android.app.Dialog;
import android.content.Context;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import com.mosai.alignpro.R;
import com.mosai.alignpro.adapter.DiagnosisHistoryAdapter;
import com.mosai.alignpro.entity.DoctorInfo;
import com.mosai.alignpro.entity.ImageInfo;

/**
 * Created by Rays on 2020/3/25.
 */
public class DiagnosisHistoryDialog extends Dialog {

    public DiagnosisHistoryDialog(@NonNull Context context, ImageInfo info, DoctorInfo doctorInfo, boolean isCanConfirm) {
        super(context, R.style.LoadingDialog);
        setContentView(R.layout.dialog_diagnosis_history);

        RecyclerView recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        recyclerView.setAdapter(new DiagnosisHistoryAdapter(context, info.getHistories(), doctorInfo, isCanConfirm, this));
    }

    @Override
    public void show() {
        super.show();
        Window window = getWindow();
        if (window == null) {
            return;
        }
        DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
        WindowManager.LayoutParams layoutParams = window.getAttributes();
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height = (int) (displayMetrics.heightPixels * 0.5);
        layoutParams.gravity = Gravity.BOTTOM;
        window.setAttributes(layoutParams);
        window.setWindowAnimations(R.style.BottomDialogAnimation);
    }
}
